package com.test.hello.controller;

import com.test.hello.service.ServiceDemo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by lcplcp on 2017/8/21.
 */
@RestController
public class HelloSpringBoot {

    @Resource
    private ServiceDemo serviceDemo;

    @RequestMapping(path = {"/helloSpringBoot"})
    public List HelloSpring (){
        return serviceDemo.queryDemo();
    }

    @RequestMapping(path = {"get/user-info"})
    public Object getUserInfo (String accessToken) {
        Map tokenRecord = serviceDemo.findAccessToken(accessToken);
        if (tokenRecord == null) {
            return "无效accessToken";
        }

        Map map = new HashMap<>();
        map.put("msg", "获取用户信息成功");
        map.put("id", "1001");
        map.put("name", "西门吹雪");
        map.put("image", "http://xxx.com/abc.jpg");
        return map;
    }

}
